<%-- 
    Document   : TPAHome
    Created on : Nov 15, 2014, 7:39:02 PM
    Author     : user
--%>

<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.Statement"%>
<%@page import="newpackage.ConnectionFactory"%>
<%@page import="java.sql.Connection"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>JSP Page</title>
    </head>
    <body background="image.jpg">
        <h1> ENSURING PRIVACY AND DATA FRESHNESS OF SHARED DATA IN CLOUD </h1>
        <center>
    
        <%! boolean checkUser(String user,String password)throws Exception
         {
      Connection con=ConnectionFactory.getConnection();
      Statement select=con.createStatement();  
    String query="Select * from user_details where user_name='"+user+"' and password='"+password+"'";
    ResultSet rs=select.executeQuery(query);
    if(rs.next())
               {
        return true;
    }
     return false;
    }
        %>
<% 
String user_name=request.getParameter("user_name");
String password=request.getParameter("password");
boolean b=checkUser(user_name, password);

if(user_name.equals("audit")&&password.equals("audit"))
 {
    session.setAttribute("user_name","auditor");
     response.sendRedirect("AuditFile.jsp");
}
else if(checkUser(user_name, password))
 {session.setAttribute("user_name",user_name);
     response.sendRedirect("ViewFile.jsp");
}
else
       {
    request.setAttribute("message","Username or password must be error");
    request.getRequestDispatcher("/Login.jsp").forward(request, response);
}



%>

    </center>    
    </body>
</html>
